#include<bits/stdc++.h>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> v;
	for (int i = 0; i < n; i++)
	{
		int num;
		cin >> num;
		v.push_back(num);
	}

	queue<int> q1;
	q1.push(0);
	queue<int> q2;
	vector<int> mk;

	while (!q1.empty() || !q2.empty())
	{
		int sum = 0;
		if (!q1.empty())
		{
			while (!q1.empty())
			{
				int cur = q1.front();
				q1.pop();
				sum += v[cur];

				if (cur * 2 + 1 < n)
					q2.push(cur * 2 + 1);

				if (cur * 2 + 2 < n)
					q2.push(cur * 2 + 2);
			}
		}
		else
		{
			while (!q2.empty())
			{
				int cur = q2.front();
				q2.pop();
				sum += v[cur];

				if (cur * 2 + 1 < n)
					q1.push(cur * 2 + 1);

				if (cur * 2 + 2 < n)
					q1.push(cur * 2 + 2);
			}
		}
		mk.push_back(sum);
	}

	//for (auto& e : mk)
	//{
	//	cout << e << ' ';
	//}

	int maxi = 0;
	for (int i = 0; i < mk.size(); i++)
	{
		if (mk[i] > mk[maxi])
			maxi = i;
	}
	cout << maxi + 1;

	return 0;
}
